package com.SouthernWall_404.age_tool.common.world.Entity;

import com.SouthernWall_404.age_tool.AgeTool;
import com.SouthernWall_404.age_tool.common.init.ModBlockEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;

public class ModBlockEntity extends BlockEntity {

    public CompoundTag modPack=new CompoundTag();

    public ModBlockEntity(BlockEntityType<?> p_155228_, BlockPos p_155229_, BlockState p_155230_) {
        super(p_155228_, p_155229_, p_155230_);
    }

    @Override
    protected void saveAdditional(CompoundTag nbt) {
        super.saveAdditional(nbt);

        saveModPack(nbt);
    }

    @Override
    public void load(CompoundTag nbt) {
        super.load(nbt);

        loadModPack(nbt);

    }

    public void loadModPack(CompoundTag nbt)
    {
        modPack=new CompoundTag();
        if(nbt.contains(AgeTool.MODID))
        {
            modPack=nbt.getCompound(AgeTool.MODID);
        }
    }

    public void saveModPack(CompoundTag nbt)
    {
        nbt.put(AgeTool.MODID,modPack);
    }
}
